import React, { useContext } from 'react'
import { Table, Button } from 'antd'
import moment from 'moment'
import IconSvg from '@/components/IconSvg'
import { messageCenterContext } from '../../context'

export default () => {
  const { examinePushRouter, pageParams, handleChangePage, paySpecialAttentionToTableData } =
    useContext(messageCenterContext)

  const columns: any = [
    {
      title: '标题',
      dataIndex: 'title',
      key: 'title',
      width: 240,
      align: 'center',
    },
    {
      title: '内容',
      dataIndex: 'content',
      key: 'content',
      width: 320,
      align: 'center',
      render: (value: string) => <div dangerouslySetInnerHTML={{ __html: value }} />,
    },
    {
      title: '时间',
      dataIndex: 'createDate',
      key: 'createDate',
      width: 320,
      align: 'center',
      render: (value: string) => <span>{value ? moment(value).format('YYYY-MM-DD  HH : mm : ss') : ''}</span>,
    },
    {
      title: '发送人',
      dataIndex: 'createUser',
      key: 'createUser',
      width: 120,
      align: 'center',
    },
    {
      title: '操作',
      fixed: 'right',
      width: 168,
      align: 'center',
      render: (text: any, record: any) => (
        <div style={{ display: 'flex', justifyContent: 'space-around', alignItems: 'center' }}>
          <Button
            type='link'
            // loading={detailUpdateLoading.includes(record.id)}
            onClick={() => examinePushRouter(record)}
          >
            <IconSvg name='cityExamine' style={{ marginRight: 5 }} />
            查看
          </Button>
        </div>
      ),
    },
  ]
  return (
    <div>
      <div>
        <Table
          rowKey='id'
          dataSource={paySpecialAttentionToTableData}
          pagination={{
            position: ['bottomRight'],
            total: pageParams.totalCount,
            onChange: (page: number, pageSize: number | undefined) => {
              if (pageSize && pageSize !== pageParams.pageSize) {
                // 更换了页数
                handleChangePage(1, pageSize || pageParams.pageSize)
                return
              }
              handleChangePage(page, pageSize || pageParams.pageSize)
            },
            current: pageParams.pageIndex,
            pageSize: pageParams.pageSize,
            showSizeChanger: true,
            // showQuickJumper: true,
            showTotal: (total: number) =>
              `共 ${total} 条记录  第 ${pageParams.pageIndex} / ${Math.ceil(total / pageParams.pageSize)}页`,
          }}
          columns={columns}
          scroll={{ x: 1268, y: 'calc(100vh - 300px)' }}
        />
      </div>
      {/* <Modal footer={null} title='查看' open={oneConfigType.isModalOpen} onCancel={oneConfigType.handleCancel}>
        <Form
          name='basic'
          form={oneConfigType.form}
          labelCol={{ span: 6 }}
          wrapperCol={{ span: 16 }}
          initialValues={{ remember: true }}
          disabled
          //   onFinish={onFinish}
          //   onFinishFailed={onFinishFailed}
          autoComplete='off'
        >
          <Form.Item label='标题' name='title' rules={[{ required: true, message: 'Please input your username!' }]}>
            <Input />
          </Form.Item>

          <Form.Item label='内容' name='content' rules={[{ required: true, message: 'Please input your password!' }]}>
            <Input />
          </Form.Item>

          <Form.Item label='时间' name='time' rules={[{ required: true, message: 'Please input your password!' }]}>
            <Input />
          </Form.Item>

          <Form.Item label='发送人' name='sender' rules={[{ required: true, message: 'Please input your password!' }]}>
            <Input />
          </Form.Item>
        </Form>
      </Modal> */}
    </div>
  )
}
